package org.f0rb.core.event;

import java.util.List;

/**
 * Class org.f0rb.core.event description goes here.
 *
 * @author Yuan Zhen
 * @version 1.0.0 11-11-16
 */
public abstract class DefaultEventManagerImpl<M> implements EventManager<DefaultEvent<M>>{

    protected abstract List<EventListener<M>> getEventListeners();

    public void fireBeforeEvent(DefaultEvent<M> event) {
        List<EventListener<M>> listeners = getEventListeners();
        for (EventListener<M> listener : listeners) {
            listener.before(event.getModel());
        }
    }

    public void fireAfterEvent(DefaultEvent<M> event) {
        List<EventListener<M>> listeners = getEventListeners();
        for (EventListener<M> listener : listeners) {
            listener.after(event.getModel());
        }
    }
}
